﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SimSpike
{
    class InputUtility
    {
        /// <summary>
        /// Converts a string represented integer value into an integer type,
        /// and validates that the converted value is larger than 0.0
        /// </summary>
        /// <param name="stringToConvert"></param>
        /// <param name="intOutValue"></param>
        /// <returns></returns>
        public static bool GetInteger(string stringToConvert, out int intOutValue)
        {
            bool goodNumber = int.TryParse(stringToConvert, out intOutValue);
            if (goodNumber)
                goodNumber = intOutValue >= 0.0;

            return goodNumber;
        }

        /// <summary>
        /// Converts a string represented double value into a double type,
        /// and validates that the converted value is larger than 0.0.
        /// </summary>
        /// <param name="stringToConvert"></param>
        /// <param name="dblOutValue"></param>
        /// <returns></returns>
        public static bool GetDouble(string stringToConvert, out double dblOutValue)
        {
            bool goodNumber = double.TryParse(stringToConvert, out dblOutValue);
            if (goodNumber)
                goodNumber = dblOutValue >= 0.0;

            return goodNumber;

        }

        /// <summary>
        /// Validates a string and returns true if the string is not null after trimming.
        /// </summary>
        /// <param name="stringToCheck"></param>
        /// <returns></returns>
        public static bool ValidateString(string stringToCheck)
        {
            string strIn = stringToCheck.Trim();
            return !string.IsNullOrEmpty(strIn);
        }

    }
}
